import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import Login from '../components/Login.vue'
import Home from '../components/Home.vue'
import Welcome from '../components/Welcome.vue'
import selectionSystem from '../components/selectionSystem.vue'
import User from '../components/user/User.vue'
import Goods from '../components/goods/Goods.vue'
import OrderInfoList from '../components/order/OrderInfoList.vue'
import PayMoney from '../components/count/PayMoney.vue'
import payMoneyECharts from '../components/count/PayMoneyECharts.vue'
import testWebSocket from '../components/websocket/TestWebSocket.vue'
import ZxnlData from '../components/niulibanshou/zxnlData.vue'
import Ldkp from '../components/ldcj/ldkp.vue'
import Syssz from '../components/ldcj/syssz.vue'
import Zcjx from '../components/ldcj/zcjx.vue'
import Zzjl from '../components/ldcj/zzjl.vue'
import Xzxcjh from '../components/xcjh/xzxcjh.vue'


const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
    {
        path: '/',
        redirect: '/login'
    },
    {
        path: '/login',
        name: 'Login',
        component: Login
    },
    {
        path: '/selectionSystem/:type',
        name: 'SelectionSystem',
        component: selectionSystem
    },
    {
        path: '/home',
        name: 'Home',
        component: Home,
        redirect: '/welcome',
        children: [
            {
                path: '/welcome/:type',
                name: 'Home',
                component: Welcome
            },
            {
                path: '/ld_kp',
                name: 'Ldkp',
                component: Ldkp
            },
            {
                path: '/zc_jx',
                name: 'Zcjx',
                component: Zcjx
            },
            {
                path: '/zz_jl',
                name: 'Zzjl',
                component: Zzjl
            },
            {
                path: '/sys_sz',
                name: 'Syssz',
                component: Syssz
            },
            {
                path: '/nl_list',
                name: 'ZxnlData',
                component: ZxnlData
            },
            {
                path: '/add_xcjh',
                name: 'Xzxcjh',
                component: Xzxcjh
            },
            {
                path: '/userRole',
                name: 'User',
                component: User
            },
            {
                path: '/goodsList',
                name: 'Goods',
                component: Goods
            },
            {
                path: '/orderInfo',
                name: 'OrderInfoList',
                component: OrderInfoList
            },
            {
                path: '/payMoney',
                name: 'PayMoney',
                component: PayMoney
            },
            {
                path: '/payMoneyECharts',
                name: 'payMoneyECharts',
                component: payMoneyECharts
            },
            {
                path: '/testWebSocket',
                name: 'TestWebSocket',
                component: testWebSocket
            }

        ]
    }
    // ,
    // {
    //   path: '/about',
    //   name: 'About',
    //   // route level code-splitting
    //   // this generates a separate chunk (about.[hash].js) for this route
    //   // which is lazy-loaded when the route is visited.
    //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
    // }
]

const router = new VueRouter({
    routes
})
//挂载路由导航守卫
// router.beforeEach((to, from, next) => {

//     if (to.path === '/login') {
//         return next();
//     }
//     const token = window.sessionStorage.getItem("token");
//     if (!token) {
//         return next('/login');
//     }
//     next();

// })

export default router
